<template>
    <div>
        <!-- 表头 -->
        <el-page-header @back="goBack" :content="comment"></el-page-header>
        <!-- 表单 -->
        <el-form size="small" ref="form" :model="form" label-width="80px">
            <el-form-item label="意见">
                    <el-input v-model="form.opinion"></el-input>
            </el-form-item>
            <el-form-item label="姓名">
                    <el-input v-model="form.name"></el-input>
            </el-form-item>
            <el-form-item label="联系方式">
                    <el-input v-model="form.phonenumber"></el-input>
            </el-form-item>
            <el-form-item>
                <div style="text-align:right">
                    <el-button type="primary" @click="submitHandler">提交</el-button>
                </div>
            </el-form-item>
        </el-form>   
    </div>
</template>
<script>
import {post} from '@/utils/request'
export default {
    data(){
        return {
            comment:"意见反馈",
            form:{}
        }
    },
    methods:{
        // 提交
        submitHandler(){
            let url="http://localhost:8888/comment/saveOrUpdate"
            post(url,this.form).then(resp=>{
                // 提示
                this.$message({type:"success",message:resp.message})
               // 返回列表面
               this.goBack();
            })
        },
        // 返回
        goBack(){
            this.$router.go(-1)
        }
    },
    created(){
        // 页面加载出来的时候，将路由中的参数拿到放到this.form中
        this.form=this.$route.query;
    }
    
}
</script>